﻿CodeMirror.tagRangeFinder=function(h,e){for(var f=RegExp("^[A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD][A-Z_a-z\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD-:.0-9\\u00B7\\u0300-\\u036F\\u203F-\\u2040]*"),b=h.getLine(e.line),a=!1,d=null,c=e.ch;!a;){c=b.indexOf("<",
c);if(-1==c)return;if(c+1<b.length&&"/"==b[c+1])c++;else if(b.substr(c+1).match(f)){var g=b.indexOf(">",c+1);if(-1==g){for(var a=e.line+1,l=!1,j=h.lineCount();a<j&&!l;){var i=h.getLine(a),g=i.indexOf(">");if(-1!=g&&(l=!0,i=i.lastIndexOf("/",g),-1!=i&&i<g&&(i=b.substr(i,g-i+1),!i.match(/\/\s*\>/))))return;a++}a=!0}else j=b.lastIndexOf("/",g),-1==j?a=!0:(i=b.substr(j,g-j+1),i.match(/\/\s*\>/)||(a=!0));a&&((d=b.substr(c+1).match(f))?(d=d[0],-1!=b.indexOf("</"+d+">",c)&&(a=!1)):a=!1);a||c++}else c++}if(a){f=
RegExp("(\\<\\/"+d+"\\>)|(\\<"+d+"\\>)|(\\<"+d+"\\s)|(\\<"+d+"$)");d="</"+d+">";c=1;a=e.line+1;for(j=h.lineCount();a<j;){b=h.getLine(a);if(b=b.match(f))for(l=0;l<b.length;l++)if(b[l]==d?c--:c++,!c)return{from:{line:e.line,ch:g+1},to:{line:a,ch:b.index}};a++}}};
CodeMirror.braceRangeFinder=function(h,e){for(var f=e.line,b=h.getLine(f),a=b.length,d,c;;){a=b.lastIndexOf("{",a);if(a<e.ch)break;c=h.getTokenAt({line:f,ch:a}).type;if(!/^(comment|string)/.test(c)){d=a;break}a-=1}if(!(null==d||b.lastIndexOf("}")>d)){var b=1,a=h.lineCount(),g,l,j=f+1;a:for(;j<a;++j)for(var i=h.getLine(j),k=0;;){var m=i.indexOf("{",k),k=i.indexOf("}",k);0>m&&(m=i.length);0>k&&(k=i.length);k=Math.min(m,k);if(k==i.length)break;if(h.getTokenAt({line:j,ch:k+1}).type==c)if(k==m)++b;else if(!--b){g=
j;l=k;break a}++k}if(!(null==g||g==f+1))return{from:{line:f,ch:d+1},to:{line:g,ch:l}}}};CodeMirror.indentRangeFinder=function(h,e){for(var f=h.getOption("tabSize"),b=h.getLine(e.line),a=CodeMirror.countColumn(b,null,f),d=e.line+1,c=h.lineCount();d<c;++d){var g=h.getLine(d);if(CodeMirror.countColumn(g,null,f)<a)return{from:{line:e.line,ch:b.length},to:{line:d,ch:g.length}}}};
CodeMirror.newFoldFunction=function(h,e){null==e&&(e="↔");if("string"==typeof e){var f=document.createTextNode(e),e=document.createElement("span");e.appendChild(f);e.className="CodeMirror-foldmarker"}return function(b,a){"number"==typeof a&&(a={line:a,ch:0});var d=h(b,a);if(d){for(var c=b.findMarksAt(d.from),g=0,f=0;f<c.length;++f)c[f].__isFold&&(++g,c[f].clear());if(!g){c=e.cloneNode(!0);CodeMirror.on(c,"mousedown",function(){j.clear()});var j=b.markText(d.from,d.to,{replacedWith:c,clearOnEnter:!0,
__isFold:!0})}}}};